//路由模块数据结构
import {RouteRecordRaw} from 'vue-router'
import Login from '../views/login/index.vue'
import NotFound from '@/components/404.vue'

let inited = false

export const HOMENAME = 'Home'
/** 基础路由设置 */
export const baseRoutes:Array<RouteRecordRaw> = [
  {
    path:'/',
    redirect:'/home'
  },
  {
    name:'Login',
    path: '/login',
    component:Login
  },
  {
    name:HOMENAME,
    path:'/home',
    component:() => import('@/views/home/index.vue')
  },
  {
    name:'404',
    path:'/404',
    component:NotFound
  },
  {
    name:'NotFound',
    path:'/:pathMatch(.*)',
    redirect:() => {
      if (inited) {
        return {name:'/404'}
      } else {
        inited = true
        return {name:HOMENAME}
      }
    }
  }
]

//主页
export const homeRoute:RouteRecordRaw = {
  name:HOMENAME,
  path:'/home',
  component:() => import('@/views/home/index.vue')
}